package com.songshuai.webapi.baseapi.exception;


import com.songshuai.webapi.baseapi.enumerations.ResultStatus;
import com.songshuai.webapi.baseapi.enumerations.miniprogram.ResponseStatus;

public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private Integer code;  //错误码

    public BusinessException() {}

    public BusinessException(ResultStatus resultEnum) {
        super(resultEnum.getErrorMsg());
        this.code = resultEnum.getErrorCode();
    }

    public BusinessException(ResponseStatus responseStatus){
        super(responseStatus.getErrorMsg());
        this.code = responseStatus.getErrorCode();
    }

    public BusinessException(String errMsg, ResultStatus resultEnum) {
        super(errMsg);
        this.code = resultEnum.getErrorCode();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
